package com.sh.动态规划;

import java.awt.event.ActionListener;

/**
 * @Auther: sh
 * @Version 1.0
 * @Description:
 */
public class 爬楼梯 {
    public static void main(String[] args) {
        System.out.println(climbStairs(5));
    }

    public static int climbStairs(int n) {
        if (n == 0 || n == 1) {
            return 1;
        }
        int[] ints = new int[n + 1];
        ints[0] = 1;
        ints[1] = 1;
        int step = 2;
        for (int i = 2; i <= n; i++) {
            for (int i1 = 1; i1 <= step; i1++) {
                if (i - step >= 0) {
                    ints[i] += ints[i-i1];
                }
            }
        }
        return ints[n];
    }
}

